<!--
 * @Author: 张久冬
 * @Date: 2021-12-21 14:51:25
 * @
# Description:
-->
<template>
  <div class="login-panel">
    <h1 class="title">后台管理系统</h1>
    <el-tabs type="border-card" stretch v-model="account">
      <el-tab-pane name="account">
        <template #label>
          <span
            ><el-icon>
              <user-filled />
            </el-icon>
            账号登录</span
          >
        </template>
        <Loginaccount ref="accountRef"></Loginaccount>
      </el-tab-pane>
      <el-tab-pane name="phone">
        <template #label>
          <span
            ><el-icon>
              <iphone />
            </el-icon>
            手机登录</span
          >
        </template>
        <Loginphone></Loginphone>
      </el-tab-pane>
    </el-tabs>
    <div class="account-control">
      <el-checkbox v-model="isKeepPassword">记住密码</el-checkbox>
      <el-link type="primary">忘记密码</el-link>
    </div>

    <el-button type="primary" class="login-btn" @click="handleLoginClick"
      >立即登录</el-button
    >
  </div>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue'
import Loginaccount from './login-account.vue'
import Loginphone from './login-phone.vue'

export default defineComponent({
  components: { Loginaccount, Loginphone },
  setup() {
    const account = ref<string>('account')
    const isKeepPassword = ref(false)
    // 拿到实例的类型
    const accountRef = ref<InstanceType<typeof Loginaccount>>()
    const handleLoginClick = () => {
      // console.log('立即登陆', accountRef.value)
      accountRef.value?.loginAction(isKeepPassword.value)
    }
    return {
      account,
      isKeepPassword,
      handleLoginClick,
      accountRef
    }
  }
})
</script>

<style scoped lang="less">
.login-panel {
  margin-bottom: 150px;
  width: 320px;

  .title {
    text-align: center;
  }

  .account-control {
    margin-top: 10px;
    display: flex;
    justify-content: space-between;
  }

  .login-btn {
    width: 100%;
    margin-top: 10px;
  }
}
</style>
